package com.aikon.wht.designPattern.async;

/**
 * @author haitao.wang
 */
public class TestOfWait {

    public static void main(String[] args) throws InterruptedException {
        T1 t1 = new T1();
        new Thread(()-> {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("UUU");
            synchronized (t1) {
                t1.notifyAll();
                System.out.println("ttt");

            }

        }).start();
        new Thread(()->{
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("JJJ");
            synchronized (t1) {
                try {
                    t1.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("EEE");

            }
        }).start();

//        synchronized (t1) {
//
//            t1.wait();
//        }
        synchronized (t1) {
            System.out.println("YYY");
            t1.wait();
        }
        System.out.println("OOO");
    }

    /**
     * @author haitao.wang
     */
    public static class T1 {


    }
}
